<template>
    <div>123</div>
</template>
<script>
// beforeRouteEnter  不能访问this  beforeRouteUpdate  beforeRouteLeave
export default {
    created(){
        this.getDetail(this.$route.params.id);
    },
    // beforeRouteEnter(to,from,next){
    //     let uid = localStorage.getItem('uid') ||'';
    //     if(uid){
    //         next()
    //     }else{
    //         next('/home')
    //     }
    // },
    beforeRouteUpdate(to,from,next){
        this.getDetail(to.params.id);
    },
    methods:{
        getDetail(id){
            this.$http.get('/api/detail',{params:{id:id}}).then((res) => {
                console.log(res)
            })
        }
    }
}
</script>
